package sandbox.psyomn;

import java.util.ArrayList;
import java.util.Date;

import Model.PeriodicTask;

public class PeriodicGateway
{
	public static void main(String[] args)
	{
		// run these one at the time, top to bottom
		// createDatabase();
		// readDatabase();
		// deleteTask();
		// update();
	}
	
	public static void createDatabase()
	{
		PeriodicTaskGateway stg = new PeriodicTaskGateway(); 
		
		PeriodicTask st1 = new PeriodicTask("task1", new Date(), "desc1");
		PeriodicTask st2 = new PeriodicTask("task2", new Date(), "desc2");
		PeriodicTask st3 = new PeriodicTask("task3", new Date(), "desc3");
		PeriodicTask st4 = new PeriodicTask("task4", new Date(), "desc4");
		
		st1.setRepeat("Daily");
		st2.setRepeat("Weekly");
		st3.setRepeat("Monthly");
				
		stg.create(st1);
		stg.create(st2);
		stg.create(st3);
	}
	
	public static void readDatabase()
	{
		PeriodicTaskGateway stg = new PeriodicTaskGateway(); 

		ArrayList<PeriodicTask> starr; 
		
		starr = stg.read();
		System.out.println(starr);
	}
	
	public static void deleteTask()
	{
		PeriodicTaskGateway stg = new PeriodicTaskGateway();
		PeriodicTask st1 = new PeriodicTask("task1", new Date(), "desc1");
		ArrayList<PeriodicTask> starr;
		
		stg.delete(st1);
		
		starr = stg.read();
		System.out.println(starr);
	}
	
	public static void update()
	{
		PeriodicTaskGateway stg = new PeriodicTaskGateway();
		PeriodicTask st1 = new PeriodicTask("task2", new Date(), "Periodic");
		ArrayList<PeriodicTask> starr;
		
		starr = stg.read();
		System.out.println(starr);
		
		st1.setRepeat("Daily");
		st1.setDone(true);
		
		/* You should observe a new timestamp for t2, and that it's done */
		stg.update(st1);
		
		starr = stg.read();
		System.out.println(starr);
	}
}
